home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Examples / A-Z / G / GridViews / Row Selection in Grid Views / UDocumentRowSelect.cp < prev    next >
Encoding:
Text File  |  1996-04-03  |  7.3 KB  |  209 lines  |  [TEXT/MPS ]

  1. //----------------------------------------------------------------------------------------
  2. // UDocumentRowSelect.cp
  3. // Copyright © 1991-96 by Apple Computer, Inc. All rights reserved. 
  4. //----------------------------------------------------------------------------------------
  5.  
  6. #ifndef __UDocumentRowSelect__
  7. #include "UDocumentRowSelect.h"
  8. #endif
  9.  
  10. // MacApp
  11.  
  12. #ifndef __UMACAPPGLOBALS__
  13. #include "UMacAppGlobals.h"
  14. #endif
  15.  
  16. #ifndef __UMENUMGR__
  17. #include "UMenuMgr.h"
  18. #endif
  19.  
  20. #ifndef __UPRINTING__
  21. #include "UPrinting.h"
  22. #endif
  23.  
  24. #ifndef __UVIEWSERVER__
  25. #include "UViewServer.h"
  26. #endif
  27.  
  28. #ifndef __UWINDOW__
  29. #include "UWindow.h"
  30. #endif
  31.  
  32. //----------------------------------------------------------------------------------------
  33. // Constants:
  34.  
  35. const ResNumber kRowSelectWindowID = kDefaultWindowID;
  36.  
  37. //========================================================================================
  38. // CLASS TDocumentRowSelect
  39. //========================================================================================
  40. #undef Inherited
  41. #define Inherited TFileBasedDocument
  42.  
  43. #pragma segment AOpen
  44. MA_DEFINE_CLASS_M1(TDocumentRowSelect, Inherited);
  45.  
  46. //----------------------------------------------------------------------------------------
  47. // TDocumentRowSelect constructor 
  48. //----------------------------------------------------------------------------------------
  49. #pragma segment AOpen
  50.  
  51. TDocumentRowSelect::TDocumentRowSelect()  
  52. {
  53. } // TDocumentRowSelect::TDocumentRowSelect 
  54.  
  55. //----------------------------------------------------------------------------------------
  56. // TDocumentRowSelect::IDocumentRowSelect: 
  57. //----------------------------------------------------------------------------------------
  58. #pragma segment AOpen
  59.         
  60. void TDocumentRowSelect::IDocumentRowSelect(TFile* itsFile,
  61.                                           OSType itsCreator)
  62. {
  63.     this->IFileBasedDocument(itsFile,itsCreator);
  64. } // TDocumentRowSelect::IDocumentRowSelect 
  65.  
  66. //----------------------------------------------------------------------------------------
  67. // TDocumentRowSelect destructor
  68. //----------------------------------------------------------------------------------------
  69. #pragma segment AClose
  70.  
  71. TDocumentRowSelect::~TDocumentRowSelect()
  72. {
  73. }
  74.  
  75. //----------------------------------------------------------------------------------------
  76. // TDocumentRowSelect::FreeData: 
  77. //----------------------------------------------------------------------------------------
  78. #pragma segment AClose
  79.  
  80. void TDocumentRowSelect::FreeData() // Override 
  81. {
  82.     Inherited::FreeData();
  83. } // TDocumentRowSelect::FreeData 
  84.  
  85. //----------------------------------------------------------------------------------------
  86. // TDocumentRowSelect::DoInitialState: 
  87. //----------------------------------------------------------------------------------------
  88. #pragma segment AOpen
  89.  
  90. void TDocumentRowSelect::DoInitialState() // Override 
  91. {
  92.     Inherited::DoInitialState();
  93. } // TDocumentRowSelect::DoInitialState 
  94.  
  95. //----------------------------------------------------------------------------------------
  96. // TDocumentRowSelect::DoMakeViews: 
  97. //----------------------------------------------------------------------------------------
  98. #pragma segment AOpen
  99.  
  100. void TDocumentRowSelect::DoMakeViews(Boolean /*forPrinting*/) // Override 
  101. {
  102.     TWindow* aWindow = NULL;
  103.     TStdPrintHandler* aHandler = NULL;
  104.     TView* aView = NULL;
  105.  
  106.     FailNIL(aWindow = gViewServer->NewTemplateWindow(kRowSelectWindowID, this));
  107.  
  108.     /*    You will likely have a different view to which you would like to 
  109.         attach a print handler. */
  110.     aView = aWindow->FirstSubView();
  111.  
  112.     aHandler = new TStdPrintHandler;
  113.     aHandler->IStdPrintHandler(this,            // its document 
  114.                                aView,            // its view 
  115.                                !kSquareDots,    // does not have square dots 
  116.                                kFixedSize,        // horzontal page size is fixed 
  117.                                kFixedSize);        // vertical page size is fixed 
  118. } // TDocumentRowSelect::DoMakeViews 
  119.  
  120. //----------------------------------------------------------------------------------------
  121. // TDocumentRowSelect::DoNeedDiskSpace: 
  122. //----------------------------------------------------------------------------------------
  123. #pragma segment AWriteFile
  124.  
  125. void TDocumentRowSelect::DoNeedDiskSpace(TFile* itsFile,
  126.                                         long& dataForkBytes,
  127.                                         long& rsrcForkBytes) // Override 
  128. {
  129.     Inherited::DoNeedDiskSpace(itsFile, dataForkBytes, rsrcForkBytes);
  130. } // TDocumentRowSelect::DoNeedDiskSpace 
  131.  
  132. //----------------------------------------------------------------------------------------
  133. // TDocumentRowSelect::DoMenuCommand: This method is overridden to handle menu items which
  134. // are enabled when this document is in the target chain. In this example, this is true
  135. // when the document is open and its window is the active window. The inherited method
  136. // should always be called so that MacApp can allow successor objects in the target chain
  137. // (i.e. the application) to handle THEIR menu items.
  138. //----------------------------------------------------------------------------------------
  139. #pragma segment ASelCommand
  140.  
  141. void TDocumentRowSelect::DoMenuCommand(CommandNumber aCommandNumber) // Override 
  142. {
  143.     switch (aCommandNumber) 
  144.     {
  145.         /*    Typically, you will have dispatch your own menu commands here:
  146.         case cCommandHandledByDocument: 
  147.             {
  148.                 TCommandRowSelect* aCommand = new TCommandRowSelect;
  149.                 aCommand->ICommandRowSelect(aCommandNumber, this);
  150.                 this->PostCommand(aCommand);
  151.             }
  152.             break;
  153.         */
  154.         default:
  155.             Inherited::DoMenuCommand(aCommandNumber);
  156.             break;
  157.     }
  158. } // TDocumentRowSelect::DoMenuCommand 
  159.  
  160. //----------------------------------------------------------------------------------------
  161. // TDocumentRowSelect::DoRead: 
  162. //----------------------------------------------------------------------------------------
  163. #pragma segment AReadFile
  164.  
  165. void TDocumentRowSelect::DoRead(TFile* aFile,
  166.                                        Boolean forPrinting) // Override 
  167. {
  168.     Inherited::DoRead(aFile,forPrinting);
  169. } // TDocumentRowSelect::DoRead 
  170.  
  171. //----------------------------------------------------------------------------------------
  172. // TDocumentRowSelect::DoSetupMenus: This method is overridden to enable menu items which
  173. // should be enabled when this object is in the target chain. MacApp initially disables
  174. // all menu items, then lets the objects in the target chain enable those items they
  175. // handle.
  176. //
  177. // A document object is in the target chain when its window is the active window.
  178. //
  179. // The inherited method is called so that TDocument can enable document-level menu items
  180. // like "Save ". This also ensures that objects further up the target chain (the
  181. // application) can set up THEIR menus.
  182. //----------------------------------------------------------------------------------------
  183. #pragma segment ARes
  184.  
  185. void TDocumentRowSelect::DoSetupMenus() // Override 
  186. {
  187.     Inherited::DoSetupMenus();
  188.     
  189.     /*    Typically, you will have enable your own menu commands here:
  190.     Enable(cCommandHandledByDocument,TRUE);
  191.     */
  192. } // TDocumentRowSelect::DoSetupMenus 
  193.  
  194. //----------------------------------------------------------------------------------------
  195. // TDocumentRowSelect::DoWrite: 
  196. //----------------------------------------------------------------------------------------
  197. #pragma segment AWriteFile
  198.  
  199. void TDocumentRowSelect::DoWrite(TFile* aFile,
  200.                                     Boolean makingCopy) // Override 
  201. {
  202.     Inherited::DoWrite(aFile,makingCopy);
  203. } // TDocumentRowSelect::DoWrite 
  204.  
  205. //----------------------------------------------------------------------------------------
  206. // End of UDocumentRowSelect.cp
  207.  
  208. #pragma segment Inline
  209.